﻿<%@ Page Language="C#" MasterPageFile="~/InventoryTracker/MasterPage.master" AutoEventWireup="true" CodeFile="NGenerated.aspx.cs" Inherits="InventoryTracker_NGenerated" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="maincontent" Runat="Server">



  
    
  
    <h3>Editing individual Grid<asp:GridView ID="GridView1" runat="server" 
            AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" 
            GridLines="None" DataSourceID="SqlDataSource1" DataKeyNames="Id"
            OnRowDataBound="GridView1_RowDataBound" 
            OnRowCommand="GridView1_RowCommand" OnRowUpdating="GridView1_RowUpdating" 
            AllowSorting="True" AllowPaging="True" PageSize="4" 
            style="top: 314px; left: 47px; position: absolute; height: 219px; width: 651px; " >
            <Columns>                
                <asp:ButtonField Text="SingleClick" CommandName="SingleClick" Visible="False"/>
                
                
                <asp:TemplateField HeaderText="Item Code" SortExpression="ItemCode">
                    <ItemTemplate>
                        <asp:Label ID="ItemCodeLabel" runat="server" Text='<%# Eval("AssignedTo") %>'></asp:Label>
                        <asp:DropDownList ID="ItemCode" runat="server" 
                            AutoPostBack="True" Visible="true"  CausesValidation="True" DataSourceID="ItemCodeDS" 
                            DataTextField="ItemCode" DataValueField="ItemCode">
                            <asp:ListItem></asp:ListItem>
                            </asp:DropDownList>
                        <asp:SqlDataSource ID="ItemCodeDS" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT [ItemCode] FROM [MaterialMaster]"></asp:SqlDataSource>
                        
                        
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Item Name" SortExpression="ItemName">
                    <ItemTemplate>
                        <asp:Label ID="ItemNameLabel" runat="server" Text='<%# Eval("AssignedTo") %>'></asp:Label>
                        <asp:DropDownList ID="ItemName" runat="server" 
                            AutoPostBack="True" CausesValidation="True" DataSourceID="ItemNameDS" 
                            DataTextField="ItemName" DataValueField="ItemName">
                            <asp:ListItem></asp:ListItem>
                            </asp:DropDownList>
                        <asp:SqlDataSource ID="ItemNameDS" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT [ItemName] FROM [MaterialMaster]"></asp:SqlDataSource>
                        
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Description" SortExpression="Description">
                    <ItemTemplate>
                        <asp:Label ID="DescLabel" runat="server" Text='<%# Eval("Status") %>'></asp:Label>
                        <asp:DropDownList ID="Description" runat="server" 
                            AutoPostBack="True" CausesValidation="True" DataSourceID="ItemDesDS" 
                            DataTextField="ItemDescription" DataValueField="ItemDescription">
                            <asp:ListItem></asp:ListItem>
                            </asp:DropDownList>
                        <asp:SqlDataSource ID="ItemDesDS" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT [ItemDescription] FROM [MaterialMaster]">
                        </asp:SqlDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Unit Rate" SortExpression="UnitRate">
                    <ItemTemplate>
                        <asp:Label ID="UnitRatLabel" runat="server" Text='<%# Eval("AssignedTo") %>'></asp:Label>
                        <asp:DropDownList ID="UnitRat" runat="server" 
                            AutoPostBack="True" CausesValidation="True" DataSourceID="ItemRateDS" 
                            DataTextField="SellingRate" DataValueField="SellingRate">
                            <asp:ListItem></asp:ListItem>
                            </asp:DropDownList>
                        
                        <asp:SqlDataSource ID="ItemRateDS" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT [SellingRate] FROM [MaterialMaster]">
                        </asp:SqlDataSource>
                       </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Quantity" SortExpression="Qty">
                    <ItemTemplate>
                        <asp:Label ID="QtyLabel" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                        <asp:TextBox ID="Qty" runat="server" Width="175px" visible="True"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Amount" SortExpression="Amt">
                    <ItemTemplate>
                        <asp:Label ID="AmtLabel" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                        <asp:TextBox ID="Amt" runat="server" Text='<%# Eval("Description") %>' 
                            Width="175px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Tax" SortExpression="Tax">
                    <ItemTemplate>
                        <asp:Label ID="TaxLabel" runat="server" Text='<%# Eval("AssignedTo") %>'></asp:Label>
                        <asp:DropDownList ID="Tax" runat="server" 
                            AutoPostBack="True" CausesValidation="True" DataSourceID="TaxDS" 
                            DataTextField="TaxName" DataValueField="TaxName">
                            <asp:ListItem></asp:ListItem>
                            </asp:DropDownList>
                        
                        <asp:SqlDataSource ID="TaxDS" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT [TaxName] FROM [TaxScheme]"></asp:SqlDataSource>
                        </ItemTemplate>
                </asp:TemplateField>
                
                  <asp:TemplateField HeaderText="Discount" SortExpression="Discount">
                    <ItemTemplate>
                        <asp:Label ID="DiscountLabel" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                        <asp:TextBox ID="Discount" runat="server" Width="175px" visible="True"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Total Amount" SortExpression="Amt">
                    <ItemTemplate>
                        <asp:Label ID="TotalAmountLabel" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                        <asp:TextBox ID="TotalAmount" runat="server" Width="175px"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                
                
                
            </Columns>
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle CssClass="headerStyle" ForeColor="White" BackColor="#5D7B9D" 
                Font-Bold="True" />
            <RowStyle CssClass="rowStyle" BackColor="#F7F6F3" ForeColor="#333333" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle CssClass="alternatingRowStyle" BackColor="White" 
                ForeColor="#284775" />
            <FooterStyle CssClass="footerStyle" BackColor="#5D7B9D" Font-Bold="True" 
                ForeColor="White" />
            <PagerStyle CssClass="pagerStyle" ForeColor="White" BackColor="#284775" 
                HorizontalAlign="Center" />
        </asp:GridView>
        <asp:SqlDataSource ID="InvDS" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            DeleteCommand="DELETE FROM InvoiceDetails WHERE (InvoiceNumber = @InvoiceNumber)" 
            InsertCommand="INSERT INTO InvoiceDetails(InvoiceItem, InvoiceItemRate, Tax, InvoiceTotalAmount, InvoiceItemQty, InvoiceDiscount) VALUES (@InvoiceItem, @InvoiceItemRate, @Tax, @InvoiceTotalAmount, @InvoiceItemQty, @InvoiceDiscount)" 
            SelectCommand="SELECT InvoiceDetails.* FROM InvoiceDetails" 
            UpdateCommand="UPDATE InvoiceDetails SET InvoiceItem = @InvoiceItem, InvoiceItemRate = @InvoiceItemRate, Tax = @Tax, InvoiceTotalAmount = @InvoiceTotalAmount, InvoiceItemQty = @InvoiceItemQty, InvoiceDiscount = @InvoiceDiscount WHERE (InvoiceNumber = @InvoiceNumber)">
            <DeleteParameters>
                <asp:Parameter Name="InvoiceNumber" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="InvoiceItem" />
                <asp:Parameter Name="InvoiceItemRate" />
                <asp:Parameter Name="Tax" />
                <asp:Parameter Name="InvoiceTotalAmount" />
                <asp:Parameter Name="InvoiceItemQty" />
                <asp:Parameter Name="InvoiceDiscount" />
                <asp:Parameter Name="InvoiceNumber" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="InvoiceItem" />
                <asp:Parameter Name="InvoiceItemRate" />
                <asp:Parameter Name="Tax" />
                <asp:Parameter Name="InvoiceTotalAmount" />
                <asp:Parameter Name="InvoiceItemQty" />
                <asp:Parameter Name="InvoiceDiscount" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="NewInvDS" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT [ItemName], [ItemDescription], [ItemCode], [SellingRate] FROM [MaterialMaster]">
        </asp:SqlDataSource>
        </h3>
    
    
    <div style="height: 55px">        
        <br />
        <asp:Label id="Message" runat="server" CssClass="message"></asp:Label> 
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            DeleteCommand="DELETE FROM [Tasks] WHERE [Id] = @Id" InsertCommand="INSERT INTO [Tasks] ([Description], [AssignedTo], [Status]) VALUES (@Description, @AssignedTo, @Status)"
            SelectCommand="SELECT * FROM [Tasks]" UpdateCommand="UPDATE [Tasks] SET [Description] = @Description, [AssignedTo] = @AssignedTo, [Status] = @Status WHERE [Id] = @Id" >
            <DeleteParameters>
                <asp:Parameter Name="Id" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="AssignedTo" Type="String" />
                <asp:Parameter Name="Status" Type="String" />
                <asp:Parameter Name="Id" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="AssignedTo" Type="String" />
                <asp:Parameter Name="Status" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>  
     </div>

</asp:Content>

